package cn.enilu.flash.service.park;


import cn.enilu.flash.bean.entity.park.ParkingQuote;
import cn.enilu.flash.bean.view.ParkQuoteView;
import cn.enilu.flash.dao.park.ParkingQuoteRepository;

import cn.enilu.flash.service.BaseService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class ParkingQuoteService extends BaseService<ParkingQuote,Long,ParkingQuoteRepository>  {
    private Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    private ParkingQuoteRepository parkingQuoteRepository;


    public List<ParkingQuote> getParkingQuotes(Long parkingId){
        List<ParkingQuote> result = null;
        List<Map<String, Object>> list = parkingQuoteRepository.getParkingQuotes(parkingId);
        if(list != null && !list.isEmpty()){
            result = new ArrayList<>();
            ParkingQuote view = null;
            for (Map<String, Object> m : list) {
                view = new ParkingQuote();
                view.setId(((BigInteger)m.get("id")).longValue());
                view.setQuoteType((Integer)m.get("quoteType"));
                view.setQuoteRange((Integer)m.get("quoteRange"));
                view.setQuoteUnit((Integer)m.get("quoteUnit"));
                view.setQuotePrice((Double)m.get("quotePrice"));
                view.setCommunityId(((BigInteger)m.get("communityId")).longValue());
                result.add(view);
            }
        }
        return result;
    }

}

